package org.future.task.core.flow;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class FlowEntry implements Serializable {

    private String taskId;

    private Object taskObj;

    private List<Map<String, Object>> flowList;

    private JsonSerializable jsonSerializable;

    private String status;

    private String queueName;

    private String nextQueue;

    private String NvType;


    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public Object getTaskObj() {
        return taskObj;
    }

    public void setTaskObj(Object taskObj) {
        this.taskObj = taskObj;
    }

    public List<Map<String, Object>> getFlowList() {
        return flowList;
    }

    public void setFlowList(List<Map<String, Object>> flowList) {
        this.flowList = flowList;
    }

    public JsonSerializable getJsonSerializable() {
        return jsonSerializable;
    }

    public void setJsonSerializable(JsonSerializable jsonSerializable) {
        this.jsonSerializable = jsonSerializable;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getQueueName() {
        return queueName;
    }

    public void setQueueName(String queueName) {
        this.queueName = queueName;
    }

    public String getNextQueue() {
        return nextQueue;
    }

    public void setNextQueue(String nextQueue) {
        this.nextQueue = nextQueue;
    }

    public String getNvType() {
        return NvType;
    }

    public void setNvType(String nvType) {
        NvType = nvType;
    }

    public <T> T getData(Class<T> tClass) {
        Object taskObj = this.getTaskObj();
        if (tClass == null) {
            return (T) taskObj;
        }
        if (taskObj instanceof String) {
            if (jsonSerializable != null) {
                return jsonSerializable.jsonToPojo((String) taskObj, tClass);
            }
        }
        return (T) taskObj;
    }

    public <T> T getData() {
        return getData(null);
    }


    @Override
    public String toString() {
        return "FlowTask{" +
                "taskId='" + taskId + '\'' +
                ", taskObj=" + taskObj +
                ", flowList=" + flowList +
                ", jsonSerializable=" + jsonSerializable +
                ", status='" + status + '\'' +
                ", queueName='" + queueName + '\'' +
                ", nextQueue='" + nextQueue + '\'' +
                ", NvType='" + NvType + '\'' +
                '}';
    }

}
